<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>数组</title>
</head>
<body>
<script>
    var x;
    var mycars=new Array();
    mycars[0]="ssab"
    mycars[1]="volovo"
    mycars[2]="bmw"
    for (x in mycars)
    {
        document.write(mycars[x]+"<br>")
    }

    var arr = new Array(3)
    arr[0] = "George"
    arr[1] = "John"
    arr[2] = "Thomas"

    var arr2 = new Array(3)
    arr2[0] = "James"
    arr2[1] = "Adrew"
    arr2[2] = "Martin"

    document.write(arr.concat(arr2))
    document.write("<br>")

    var arr1 = new Array(3);
    arr1[0] = "George"
    arr1[1] = "John"
    arr1[2] = "Thomas"

    document.write(arr1.join());

    document.write("<br />");

    document.write(arr1.join("."));
    document.write("<br>")

    var arr3 = new Array(6)
    arr3[0] = "George"
    arr3[1] = "John"
    arr3[2] = "Thomas"
    arr3[3] = "James"
    arr3[4] = "Adrew"
    arr3[5] = "Martin"

    document.write(arr3 + "<br />")
    document.write(arr3.sort())
    document.write("<br>")

    var arr4 = new Array(6)
    arr4[0] = "10"
    arr4[1] = "5"
    arr4[2] = "40"
    arr4[3] = "25"
    arr4[4] = "1000"
    arr4[5] = "1"

    function sortNumber(a, b)
    {
        return a - b
    }
    document.write(arr4 + "<br />")
    document.write(arr4.sort(sortNumber))
</script>
</body>
</html>